import {IRoute} from 'umi';

/**
 * @name umi 的路由配置
 * @description 只支持 path,component,routes,redirect,wrappers,title 的配置
 * @param path  path 只支持两种占位符配置，第一种是动态参数 :id 的形式，第二种是 * 通配符，通配符只能出现路由字符串的最后。
 * @param component 配置 location 和 path 匹配后用于渲染的 React 组件路径。可以是绝对路径，也可以是相对路径，如果是相对路径，会从 src/pages 开始找起。
 * @param routes 配置子路由，通常在需要为多个路径增加 layout 组件时使用。
 * @param redirect 配置路由跳转
 * @param wrappers 配置路由组件的包装组件，通过包装组件可以为当前的路由组件组合进更多的功能。 比如，可以用于路由级别的权限校验
 * @doc https://umijs.org/docs/guides/routes
 */

export const routes = [
  {path: "/", title: 'menu.home', component: "HomePage"},
  {path: "/journal", title: 'menu.journal', component: "JournalPage"},
  {
    path: "/journal/:journalId",
    title: 'menu.journal',
    component: "JournalPage/JournalDetail",
    routes: [
      {path: '/journal/:journalId', redirect: '/journal/:journalId/home'},
      {path: "/journal/:journalId/home", title: 'menu.journal', component: "JournalPage/JournalDetail/JournalDetailHome"},
      {
        path: "/journal/:journalId/archive",
        title: 'menu.journal',
        component: "JournalPage/JournalDetail/JournalArchiveBrowsing",
        routes: [
          {path: '/journal/:journalId/archive', redirect: '/journal/:journalId/archive/period'},
          {path: '/journal/:journalId/archive/period', title: 'menu.journal', component: "JournalPage/JournalDetail/commons/JournalPeriodList"},
          {path: '/journal/:journalId/archive/column', title: 'menu.journal', component: "JournalPage/JournalDetail/commons/JournalColumnList"},
        ]
      },
      {path: "/journal/:journalId/intro", title: 'menu.journal', component: "JournalPage/JournalDetail/JournalIntroduction"},
      {path: "/journal/:journalId/download", title: 'menu.journal', component: "JournalPage/JournalDetail/JournalDocDownload"},
      {path: "/journal/:journalId/stats", title: 'menu.journal', component: "JournalPage/JournalDetail/JournalStatistic"},
      {path: "/journal/:journalId/guide", title: 'menu.journal', component: "JournalPage/JournalDetail/JournalGuide"},
      {path: "/journal/:journalId/article/*", title: 'menu.journal', component: "JournalPage/JournalDetail/JournalArticleDetail"},
      {path: "/journal/:journalId/news/*", title: 'menu.journal', component: "JournalPage/JournalDetail/JournalNewsDetail"},
    ]
  },
  {
    path: "/article/*",
    title: 'menu.journal',
    component: "JournalPage/JournalDetail/JournalArticleDetail",
  },
  {
    path: "/news/*",
    title: 'menu.news',
    component: "NewsPage/NewsDetail",
  },
  {
    path: "/expert/*",
    title: 'menu.expert',
    component: "SearchPage/SearchExpert/ExpertDetail",
  },
  {
    path: "/mine",
    title: 'menu.mine',
    component: "MinePage",
    routes: [
      {path: '/mine', redirect: '/mine/favorite/journal-period'},
      {
        path: '/mine/favorite',
        title: 'menu.mine',
        component: "MinePage/Favorite",
        routes: [
          {path: '/mine/favorite', redirect: '/mine/favorite/journal-period'},
          {path: '/mine/favorite/journal-period', title: 'menu.mine', component: "MinePage/Favorite/FavoriteJournalPeriod"},
          {path: '/mine/favorite/column', title: 'menu.mine', component: "MinePage/Favorite/FavoriteColumn"},
          {path: '/mine/favorite/article', title: 'menu.mine', component: "MinePage/Favorite/FavoriteArticle"},
        ]
      },
      {
        path: "/mine/sysmsg",
        title: 'menu.mine',
        component: "MinePage/SysMsg",
        routes: [
          {path: '/mine/sysmsg', redirect: '/mine/sysmsg/unread'},
          {path: '/mine/sysmsg/unread', title: 'menu.mine', component: "MinePage/SysMsg/SysMsgUnread"},
          {path: '/mine/sysmsg/all', title: 'menu.mine', component: "MinePage/SysMsg/SysMsgAll"},
        ]
      },
      {path: "/mine/footprint", title: 'menu.mine', component: "MinePage/Footprint"},
      {path: "/mine/passport", title: 'menu.mine', component: "MinePage/Passport"},
      {path: "/mine/subscription", title: 'menu.mine', component: "MinePage/Subscription"},
    ]
  },
  {path: "/search-adv", title: 'text.search', component: "SearchPage/AdvSearch"},
  {
    path: "/search-adv",
    title: 'text.search',
    routes: [
      {path: '/search-adv', title: 'text.search', component: 'SearchPage/AdvSearch'},
      {path: '/search-adv/article', title: 'text.search', component: "SearchPage/AdvSearch/AdvSearchArticle"},
      {path: '/search-adv/special-column/:specialColumnId/article', title: 'text.search', component: "SearchPage/AdvSearch/AdvSearchSpecialColumnArticle"},
      {path: '/search-adv/help', title: 'text.search', component: "SearchPage/AdvSearch/AdvSearchHelp"},
    ]
  },
  {path: "/search", title: 'text.search', component: "SearchPage"},
  {
    path: "/search",
    title: 'text.search',
    component: "SearchPage",
    routes: [
      {path: '/search', redirect: '/search/article'},
      {path: '/search/article', title: 'text.search', component: "SearchPage/SearchArticle"},
      {path: '/search/consensus', title: 'text.search', component: "SearchPage/SearchConsensus"},
      {path: '/search/guide', title: 'text.search', component: "SearchPage/SearchGuide"},
      {path: '/search/journal', title: 'text.search', component: "SearchPage/SearchJournal"},
      {path: '/search/chart', title: 'text.search', component: "SearchPage/SearchChart"},
      {path: '/search/video', title: 'text.search', component: "SearchPage/SearchVideo"},
      {path: '/search/expert', title: 'text.search', component: "SearchPage/SearchExpert"},
    ]
  },

  {path: "/guide", title: 'menu.guide', component: "GuidePage"},
  {path: "/mall", title: 'menu.mall', component: "MallPage"},
  {path: "/mall/product/:journalId", title: 'menu.mall', component: "MallPage/MallProductDetail"},
  {path: "/about", title: 'menu.about', component: "AboutPage"},
  {path: "/privacy-policy", title: 'text.user-privacy-policy', component: "AboutPage/PrivacyPolicy"},
  {path: "/legal-agreement", title: 'text.legal-agreement', component: "AboutPage/LegalAgreement"},
  {path: "/login", title: 'text.login', component: "AuthPage/LoginPage", wrappers: ['AuthPage/AuthWrapper']},
  {path: "/register", title: 'text.register', component: "AuthPage/RegisterPage", wrappers: ['AuthPage/AuthWrapper']},
  {path: "/forgot", title: 'text.forgot', component: "AuthPage/ForgotPage", wrappers: ['AuthPage/AuthWrapper']},
  {path: '*', title: '404', component: '404Page'},
]

export default routes;
